import time


class TimeTool:

    TIME_FMT = '%Y-%m-%d %H:%M:%S'
    DATE_FMT = '%Y-%m-%d'

    @staticmethod
    def formatCurrentTime(fmt=TIME_FMT):
        '''
        格式化当前时间为获取指定格式
        '''
        return time.strftime(fmt)

    @staticmethod
    def formatTime(seconds, fmt=TIME_FMT):
        '''
        格式化指定时间为获取指定格式
        '''
        return time.strftime(fmt, time.localtime(seconds))

    @staticmethod
    def parseTime(fmtTime, fmt=TIME_FMT):
        '''
        解析指定时间格式为时间
        '''
        return int(time.mktime(time.strptime(fmtTime, fmt)))

    @staticmethod
    def getCurrentTime():
        '''
        获取当前时间
        '''
        return int(time.time())

    @staticmethod
    def getDayTime(offset=0):
        '''
        获取当前时间
        '''
        seconds = int(time.time()) + 86400 * offset
        fmtTime = time.strftime(TimeUtil.DATE_FMT, time.localtime(seconds))
        return int(time.mktime(time.strptime(fmtTime, TimeUtil.DATE_FMT)))
